/*******************************************************************************
 * Copyright (c) 2003 Boris Pruessmann and others. All rights reserved. This
 * program and the accompanying materials are made available under the terms of
 * the Common Public License v0.5 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors: Boris Pruessmann - Initial implementation
 ******************************************************************************/
package net.sourceforge.perforce.internal.api;

import java.io.InputStream;

import org.eclipse.core.runtime.Path;

import net.sourceforge.perforce.core.api.IResolvedResult;
import net.sourceforge.perforce.core.internal.api.Resolved;
import net.sourceforge.perforce.core.syncinfo.ResourceSyncInfo;

/**
 * @author <a href="mailto:bpruessmann@users.sourceforge.net">Boris
 *         Pruessmann</a>
 * @version $Revision: 488 $
 */
public class ResolvedTest extends ClientUserTestCase {
  // ---------------------------------------------------------------------------
  // Private Variables

  /** Stores the Resolved object. */
  private Resolved clientUser;

  // -------------------------------------------------------------------------
  // Public Constructors

  /**
   * Constructor for ResolveTest.
   * 
   * @param name the name of the test.
   */
  public ResolvedTest(String name) {
    super(name);
  }

  //----------------------------------------------------------------------------
  // -- Public Methods

  public void testResolved1() throws Exception {
    InputStream script = getClass().getResourceAsStream("resolved_test1.xml");
    executeScript(script, clientUser);

    IResolvedResult[] result = clientUser.getResult();
    assertEquals(1, result.length);

    assertEquals(ResourceSyncInfo.ACTION_BRANCH, result[0].getAction());
    assertEquals(
        "//p4eclipse/net.sourceforge.perforce.api/src/net/sourceforge/perforce/api/IClientUserDelegate.java",
        result[0].getDepotFilename());
    assertEquals(
        new Path(
            "c:\\Sources\\Perforce\\p4eclipse\\net.sourceforge.perforce.api\\src\\net\\sourceforge\\perforce\\api\\IClientUserDelegate2.java"),
        result[0].getLocation());
  }

  // ---------------------------------------------------------------------------
  // Protected Methods

  @Override
  protected void setUp() throws Exception {
    super.setUp();

    clientUser = Resolved.newInstance();
  }
}
